package com.whfc.ms.api.fmam.service.impl;

import com.whfc.common.result.ListData;
import com.whfc.common.result.PageData;
import com.whfc.entity.dto.OssPathDTO;
import com.whfc.fmam.entity.dto.*;
import com.whfc.fmam.entity.qo.RecvSendAnalysisQO;
import com.whfc.fmam.service.FmamWeighNoteService;
import com.whfc.fuum.entity.SysUser;
import com.whfc.ms.api.fmam.service.MatAnalysisService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;

/**
 * @Author: ；likang
 * @Description: 物资统计分析服务
 * @Date:Create：in 2019/12/9 11:33
 * @Version：1.0
 */
@Service
public class MatAnalysisServiceImpl implements MatAnalysisService {

    @DubboReference(interfaceClass = FmamWeighNoteService.class, version = "1.0.0")
    private FmamWeighNoteService fmamWeighNoteService;

    /**
     * 供应商供货统计明细列表服务
     *
     * @return
     * @Param request
     */
    @Override
    public FmamSendDetailAnaDTO sendSupplierList(RecvSendAnalysisQO request) {
        FmamSendDetailAnaDTO sendDetailDTO = fmamWeighNoteService.sendSupplierList(request);
        return sendDetailDTO;
    }

    /**
     * 供应商偏差情况分析超负差数列表服务
     *
     * @param request
     * @return
     */
    @Override
    public List<FmamSendSupplierDTO> supplierDiffNumRank(RecvSendAnalysisQO request) {
        List<FmamSendSupplierDTO> supplierDTOS = fmamWeighNoteService.getSupplierDiffNum(request);
        return supplierDTOS;
    }

    /**
     * 供应商偏差情况分析超负差率列表服务
     *
     * @param request
     * @return
     */
    @Override
    public List<FmamSendSupplierDTO> supplierDiffRateRank(RecvSendAnalysisQO request) {
        List<FmamSendSupplierDTO> supplierDTOS = fmamWeighNoteService.getSupplierDiffRate(request);
        return supplierDTOS;
    }

    @Override
    public FmamRecvSendAnaDTO analysisByMat(SysUser user, RecvSendAnalysisQO request) {
        FmamRecvSendAnaDTO fmamRecvSendAnaByMatDTO = fmamWeighNoteService.analysisByMat(request);
        return fmamRecvSendAnaByMatDTO;
    }

    @Override
    public PageData<FmamRecvSendAnaMatDTO> getWeighNoteListByMatId(Integer pageNum, Integer pageSize, Long matId, Integer type, Integer diffResult) {
        PageData<FmamRecvSendAnaMatDTO> pageData = fmamWeighNoteService.getWeighNoteListByMatId(pageNum, pageSize, matId, type, diffResult);
        return pageData;
    }

    @Override
    public FmamRecvSendAnaDTO analysisByMatType(RecvSendAnalysisQO request) {
        FmamRecvSendAnaDTO recvSendAnaDTO = fmamWeighNoteService.analysisByMatType(request);
        return recvSendAnaDTO;
    }

    @Override
    public PageData<FmamRecvSendAnaMatDTO> getWeighNoteListByMatType(Integer pageNum, Integer pageSize, Long matTypeId, Integer type, Integer diffResult) {
        PageData<FmamRecvSendAnaMatDTO> pageData = fmamWeighNoteService.getWeighNoteListByMatType(pageNum, pageSize, matTypeId, type, diffResult);
        return pageData;
    }

    /**
     * 按供应商分组进行汇总分析
     *
     * @param request
     * @return
     */
    @Override
    public List<FmamSendSupplierDTO> analysisBySupplier(RecvSendAnalysisQO request) {
        List<FmamSendSupplierDTO> fmamSendSupplierDTOS = fmamWeighNoteService.analysisBySupplier(request);
        return fmamSendSupplierDTOS;
    }


    @Override
    public ListData<FmamSupplierAnaMatDTO> supplierAnaByMatGroup(RecvSendAnalysisQO request) {
        ListData<FmamSupplierAnaMatDTO> listData = fmamWeighNoteService.supplierAnaByMatGroup(request);
        return listData;
    }

    /**
     * 供应商偏差分析数据汇总统计
     *
     * @param request
     * @return
     */
    @Override
    public FmamRecvSendAnaDTO analysisDiffData(RecvSendAnalysisQO request) {
        return fmamWeighNoteService.analysisDiffData(request);
    }


    @Override
    public PageData<FmamRecvSendAnaMatDTO> getWeighNoteListBySupplier(Integer sendSupplierId, Integer pageNum, Integer pageSize, Integer diffResult) {
        return fmamWeighNoteService.getWeighNoteListBySupplier(sendSupplierId, pageNum, pageSize, diffResult);
    }

    @Override
    public OssPathDTO exportAnalysisByMatData(RecvSendAnalysisQO request) throws IOException {
        String path = fmamWeighNoteService.exportAnalysisByMatData(request);
        OssPathDTO ossPathDTO = new OssPathDTO();
        ossPathDTO.setPath(path);
        return ossPathDTO;
    }

    @Override
    public OssPathDTO exportAnalysisBySupplierData(RecvSendAnalysisQO request) throws IOException {
        String path = fmamWeighNoteService.exportAnalysisBySupplierData(request);
        OssPathDTO ossPathDTO = new OssPathDTO();
        ossPathDTO.setPath(path);
        return ossPathDTO;
    }
}
